Public Class Candle

    Enum EPriceInCandleType
        Open
        Close
        High
        Low
        Top
        Bottom
        Current
    End Enum
    Enum ECandleTrendType
        Bullish
        Bearish
        Neutral
    End Enum
    Enum ECandleBodyType
        BearishMarubozu
        BullishMarubozu
        LongLeggedDoji
        DragonflyDoji
        etcetcetcetc
    End Enum

    Dim OpenBidPrice As Double
    Dim HighBidPrice As Double
    Dim CloseBidPrice As Double
    Dim LowBidPrice As Double

    Dim CurrentSpread As Double
    Dim CurrentBidPrice As Double

    Public Volume As Integer

    Public ReadOnly Property OpenClosePriceDifference() As Double
        Get
            Return Me.OpenBidPrice - Me.CloseBidPrice
        End Get
    End Property
    Public ReadOnly Property ExtremeValuesPriceDifference() As Double
        Get
            Return Me.HighBidPrice - Me.LowBidPrice
        End Get
    End Property
    Public Property BidPrice(ByVal PriceInCandleType As EPriceInCandleType) As Double
        Get
            Select Case PriceInCandleType
                Case EPriceInCandleType.Close
                    Return CloseBidPrice
                Case EPriceInCandleType.Current
                    Return CurrentBidPrice
                Case EPriceInCandleType.High
                    Return HighBidPrice
                Case EPriceInCandleType.Low
                    Return LowBidPrice
                Case EPriceInCandleType.Open
                    Return OpenBidPrice
                Case EPriceInCandleType.Bottom
                    Return Math.Min(OpenBidPrice, CloseBidPrice)
                Case EPriceInCandleType.Top
                    Return Math.Max(OpenBidPrice, CloseBidPrice)
            End Select
        End Get
        Set(ByVal value As Double)
            Select Case PriceInCandleType
                Case EPriceInCandleType.Close
                    CloseBidPrice = value
                Case EPriceInCandleType.Current
                    CurrentBidPrice = value
                Case EPriceInCandleType.High
                    HighBidPrice = value
                Case EPriceInCandleType.Low
                    LowBidPrice = value
                Case EPriceInCandleType.Open
                    OpenBidPrice = value
                Case EPriceInCandleType.Bottom, EPriceInCandleType.Top
                    Throw New Exception("Bottom and Top properties are ReadOnly")
            End Select
        End Set
    End Property
    Public ReadOnly Property AskPrice(ByVal PriceInCandleType As EPriceInCandleType, ByVal currentSpread As Double) As Double
        Get
            Me.CurrentSpread = currentSpread
            Return BidPrice(PriceInCandleType) + currentSpread
        End Get
    End Property

    Public ReadOnly Property CandleTrendType(ByVal PipsThresholdForNeutralCandle As Double, ByVal PipValueInQuoteCurrency As Double) As ECandleTrendType
        Get
            If Math.Abs(OpenClosePriceDifference) <= PipsThresholdForNeutralCandle * PipValueInQuoteCurrency Then
                Return ECandleTrendType.Neutral
            Else
                If OpenClosePriceDifference > 0 Then
                    Return ECandleTrendType.Bullish
                Else
                    Return ECandleTrendType.Bearish
                End If
            End If
        End Get
    End Property

    Sub New(ByVal openBidPrice As Double, ByVal highBidPrice As Double, ByVal closeBidPrice As Double, ByVal lowBidPrice As Double)
        Me.OpenBidPrice = openBidPrice
        Me.HighBidPrice = highBidPrice
        Me.CloseBidPrice = closeBidPrice
        Me.LowBidPrice = lowBidPrice
    End Sub

End Class